package com.gientech.redisconsumer.controller;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * com.gientech.producer.controller
 *
 * @author: Hero
 * @version: 1.0
 * @date: 2023/2/18
 * @ApiNote: 描述
 * TODO
 **/
@RestController
public class RedisConsumer {
    @Resource
    RedisTemplate redisTemplate;
    //常量化Key
    public static final String KEY = "myconfig";

    @GetMapping("/consumer")
    public String consumer(){
//        获取key值
        Object value = redisTemplate.opsForValue().get(KEY);
        if (value == null){
            return "没有查询到key【"+KEY+"】的值";
        }
        return "查询到的 key:value= "+KEY + " ： "+ value;
    }
}
